package com.aspose.cells;

class zbvk implements zaik {
   private zahn a;
   private zagu[] b;
   private zbvj c;
   private boolean d;
   private boolean e;
   private int f;
   private int g;
   private int h;
   private int i;
   private int j;
   private zagu k;
   private boolean l = true;
   private zagu m;

   public zbvk(zahn var1, zagu var2, int var3, int var4, int var5, boolean var6) {
      this.a = var1;
      this.b = new zagu[var4 - var3 + 1];
      this.c = new zbvj(this.b.length);
      if (var2 != null) {
         this.b(var2);
      } else {
         this.l = true;
      }

      this.f = var5;
      this.d = var6;
      this.e = false;
      this.h = -var3;
      this.g = 0;
      this.i = Math.min(this.b.length, this.h + this.f);
   }

   public zbvk(zagu[] var1, zahn var2, zagu var3, int var4, int var5, int var6, boolean var7, boolean var8, zbvj var9) {
      this.b = var1;
      this.a = var2;
      this.c = var9;
      if (var3 != null) {
         this.b(var3);
      } else {
         this.l = true;
      }

      this.d = var7;
      this.e = var8;
      this.g = var6;
      this.f = var5;
      this.h = var4;
      this.i = Math.min(this.b.length, this.h + this.f);
   }

   public zaik a(zahn var1) {
      return new zbvk(this.b, var1, this.k, this.h, this.f, this.g, this.d, this.e, this.c);
   }

   public void a() {
      this.j = Math.max(this.h - 1, -1);
   }

   public boolean b() {
      ++this.j;
      if (this.j < this.i) {
         this.m = this.b[this.j];
         if (this.l || this.m != this.k) {
            return true;
         }

         ++this.j;
         if (this.j < this.i) {
            do {
               this.m = this.b[this.j];
               if (this.l || this.m != this.k) {
                  return true;
               }

               ++this.j;
            } while(this.j != this.i);

            return false;
         }
      }

      return false;
   }

   public boolean a(int var1, int var2) {
      return this.a(this.d ? var1 : var2);
   }

   public boolean a(int var1) {
      var1 += this.h;
      if (var1 <= 0) {
         this.j = -1;
      } else {
         if (var1 == this.j) {
            return this.j < this.i;
         }

         if (var1 >= this.i) {
            this.j = this.i;
            return false;
         }

         this.j = var1 - 1;
      }

      return this.b();
   }

   public zagu c() {
      return this.m;
   }

   public int d() {
      return this.d ? this.j - this.h : 0;
   }

   public int e() {
      return this.d ? 0 : this.j - this.h;
   }

   public int f() {
      return this.j - this.h;
   }

   public zahn a(zaay var1, int var2) {
      if (!this.c.a()) {
         return null;
      } else {
         zagu var3 = null;
         int var5 = this.f;
         if (var1.k) {
            if (this.d) {
               if (this.a.x() && !var1.l.c()) {
                  var5 += var1.l.e() - 1;
               }
            } else if (this.a.y() && !var1.l.d()) {
               var5 += var1.l.f() - 1;
            }
         }

         int var4;
         if (var5 > this.c.b()) {
            if (this.k == null) {
               this.k = this.a.p();
               if (this.k == null) {
                  return null;
               }
            }

            var3 = this.k;
            var4 = var5 - this.c.b() + this.c.c(var3);
         } else {
            var3 = this.c.d();
            if (var3 == null) {
               var3 = this.k;
            }

            var4 = this.c.c(var3);
            if (var3 == null) {
               var3 = this.k;
            }
         }

         if (var4 >= var5) {
            return this.d ? new zawz(var3, var2, this.f, 1) : new zawz(var3, var2, 1, this.f);
         } else {
            int var6;
            if (var3 == zyx.a) {
               var6 = this.c.c(zyw.a);
               if (var4 + var6 >= var5) {
                  return zayc.a(this.b, zyx.a, zyw.a, var2, this.c.c(zyx.a), 0, this.b.length, this.h, this.f, this.d, this.g, this.e);
               }
            } else if (var3 == zyw.a) {
               var6 = this.c.c(zyx.a);
               if (var4 + var6 >= var5) {
                  return zayc.a(this.b, zyx.a, zyw.a, var2, this.c.c(zyx.a), 0, this.b.length, this.h, this.f, this.d, this.g, this.e);
               }
            }

            for(var6 = 0; var6 < this.b.length; ++var6) {
               if (this.b[var6] != var3) {
                  for(int var7 = this.b.length - 1; var7 > var6; --var7) {
                     if (this.b[var7] != var3) {
                        zagu[] var8;
                        for(var8 = new zagu[var7 - var6 + 1]; var7 >= var6; --var7) {
                           var8[var7 - var6] = this.b[var7];
                        }

                        return new zawg(var8, this.d, this.h - var6, this.f, var2, var3, this.g, this.e);
                     }
                  }

                  if (this.d) {
                     return new zaxh(this.b[var6], var3, var2, this.f, 1, var6 - this.h, 0, this.g, 0, this.e, false);
                  }

                  return new zaxh(this.b[var6], var3, var2, 1, this.f, 0, var6 - this.h, 0, this.g, false, this.e);
               }
            }

            if (this.d) {
               return new zawz(var3, var2, this.f, 1);
            } else {
               return new zawz(var3, var2, 1, this.f);
            }
         }
      }
   }

   public zaik b(int var1) {
      return this;
   }

   public zaik c(int var1) {
      return this;
   }

   public void a(zaay var1) {
      if (this.e) {
         if (this.d) {
            if (var1.g != this.g) {
               this.h += var1.g - this.g;
               this.g = var1.g;
               this.i = Math.min(this.b.length, this.h + this.f);
            }
         } else if (var1.h != this.g) {
            this.h += var1.h - this.g;
            this.g = var1.h;
            this.i = Math.min(this.b.length, this.h + this.f);
         }
      }

   }

   public void b(int var1, int var2) {
      this.d(this.d ? var1 : var2);
   }

   public void d(int var1) {
      var1 += this.h;
      if (var1 > this.j) {
         if (this.l) {
            this.b(this.a.o());
         }

         this.b[this.j] = this.k;
         this.c.c();
         ++this.j;
         if (var1 > this.j) {
            do {
               if (this.b[this.j] == null) {
                  this.b[this.j] = this.k;
                  this.c.c();
               }

               ++this.j;
            } while(this.j != var1);
         }

         this.m = this.b[var1];
      }

   }

   public void g() {
      if (this.j < this.i) {
         if (this.l) {
            this.b(this.a.o());
         }

         this.b[this.j] = this.k;
         this.c.c();
         ++this.j;
         if (this.j < this.i) {
            do {
               if (this.b[this.j] == null) {
                  this.b[this.j] = this.k;
                  this.c.c();
               }

               ++this.j;
            } while(this.j != this.i);
         }
      }

   }

   public void a(zagu var1) {
      this.m = this.c.b(var1);
      this.b[this.j] = this.m;
   }

   public zagu c(int var1, int var2) {
      return this.e(this.d ? var1 : var2);
   }

   public zagu e(int var1) {
      var1 += this.h;
      if (var1 >= 0 && var1 < this.i) {
         return this.b[var1];
      } else {
         if (this.l) {
            this.b(this.a.o());
         }

         return this.k;
      }
   }

   public void a(int var1, int var2, zagu var3) {
      if (this.d) {
         this.b[var1 + this.h] = this.c.b(var3);
      } else {
         this.b[var2 + this.h] = this.c.b(var3);
      }

   }

   private void b(zagu var1) {
      this.l = false;
      this.k = this.c.a(var1);
   }
}
